package com.make.house.api;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Created by xujun on 2017/11/22.
 * 接口文档的配置，和application放到同一级
 * 访问：http://localhost:8083/swagger-ui.html
 */
@Configuration
@EnableSwagger2
public class Swagger2Config {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.make.house.api.controller"))
//                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("临时抱佛脚接口文档API")
                .description("努力才能成功，成功才能让我们更幸福！！！")
                .license("接口的公共参数说明Git地址")
                .licenseUrl("https://gitee.com/xujun6564/EngineeringCalculation_doc/blob/master/接口文档/API参数说明.md")
                .contact("临时抱佛脚-小徐")
                .version("1.0")
                .build();
    }

}